'use strict'

const fs = require('fs');
const Promise = require('bluebird');

// 异步
exports.readFileAsync = (fpath, encoding) => {
    return new Promise((resolve, reject) => {
        fs.readFile(fpath, encoding, (err, content) => {
            if(err) reject(err);
            else resolve(content);
        });
    });
};

exports.writeFileAsync = (fpath, content) => {
    return new Promise((resolve, reject) => {
        fs.writeFile(fpath, content, (err, content) => {
            if(err) reject(err);
            else resolve();
        });
    });
};